package com.example.a2209_shop.fg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.a2209_shop.R
import com.example.a2209_shop.adapter.ScAdapter
import com.example.a2209_shop.database.DataBaseUtils
import com.example.a2209_shop.databinding.FragmentGkBinding
import com.example.base.mvvm.BaseViewFragment


class GkFragment :  BaseViewFragment<FragmentGkBinding>() {
    lateinit var scAdapter: ScAdapter
    override fun initData() {

    }

    override fun initView() {
        scAdapter  = ScAdapter()
        binding.rv.adapter = scAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)
    }

    override fun getLayout(): Int  = R.layout.fragment_gk

    override fun onResume() {
        super.onResume()
        val data = DataBaseUtils.getDb().getGoodsDao().queyAll()
        scAdapter.data.clear()
        scAdapter.data.addAll(data)
        scAdapter.notifyDataSetChanged()
    }

}